package com.jihui.enterprise.controller;

import com.jihui.enterprise.model.EnterpriseManager;
import com.jihui.enterprise.model.JihuiEnterprise;
import com.jihui.user.model.JihuiUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by wangjin on 2017/5/19.
 */
@Controller
public class TestController {

    @Autowired
    private EnterpriseManager enterpriseManager;
   // @Autowired
    //private UserService userService;

//    @RequestMapping(value = "/test", method = RequestMethod.GET)
//    @ResponseBody
//    public Integer add() {
//        return userManagerStart.add(10, 20);
//    }

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @ResponseBody
    public String test(@AuthenticationPrincipal JihuiUser jihuiUser) {
        JihuiEnterprise jihuiEnterprise = new JihuiEnterprise();
        jihuiEnterprise.setUserId(jihuiUser.getId());
        jihuiEnterprise.setName("asdf");
        enterpriseManager.save(jihuiEnterprise);
        return "asdf";
    }

}
